package com.bupt.liutong.admin.sch.dao;

import java.util.List;

import com.bupt.liutong.admin.core.base.Ibatis;
import com.bupt.liutong.admin.core.base.Photo;
import com.bupt.liutong.admin.core.base.PhotoDao;
import com.bupt.liutong.admin.sch.dto.AlbumPhoto;

public class AlbumPhotoDao implements PhotoDao {

	private Ibatis ibatis;

	@SuppressWarnings("unchecked")
	public List<AlbumPhoto> getAlbumPhotosByPage(AlbumPhoto albumPhoto) {
		return (List<AlbumPhoto>) ibatis.queryForPage("sch_album_photo.getAlbumPhotos", albumPhoto);
	}

	public AlbumPhoto getAlbumPhotoById(Integer id) {
		return (AlbumPhoto) ibatis.queryForObject("sch_album_photo.getAlbumPhotoById", id);
	}

	public Integer insertAlbumPhoto(AlbumPhoto albumPhoto) {
		return (Integer) ibatis.insert("sch_album_photo.insertAlbumPhoto", albumPhoto);
	}

	public void updateAlbumPhoto(AlbumPhoto albumPhoto) {
		ibatis.update("sch_album_photo.updateAlbumPhoto", albumPhoto);
	}

	public void deleteAlbumPhoto(Integer id) {
		ibatis.delete("sch_album_photo.deleteAlbumPhoto", id);
	}

	public void setIbatis(Ibatis ibatis) {
		this.ibatis = ibatis;
	}

	public Photo deletePhoto(Integer id) {
		Photo photo = this.getAlbumPhotoById(id);
		this.deleteAlbumPhoto(id);
		return photo;
	}

	public void insertPhoto(Photo photo) {
		this.insertAlbumPhoto((AlbumPhoto) photo);
	}

	public void updatePhoto(Photo photo) {
		this.updateAlbumPhoto((AlbumPhoto) photo);
	}
}
